<template>
  <div class="raider_detail_wrap">
    <el-button type="text" @click="back"
      >返回首页</el-button
    >
    <div class="content_wrap">
      <div class="title">{{ content.title }}</div>
      <div class="writer">发表人：{{ content.username || "--" }}</div>
      <div class="createTime">发表时间：{{ content.createTime || "--" }}</div>
      <el-carousel height="150px" v-if="pics.length > 2">
        <el-carousel-item v-for="(item, index) in pics" :key="index">
          <el-image :src="item" fit="fill"></el-image>
        </el-carousel-item>
      </el-carousel>
      <div v-else>
        <el-image
          v-for="(item, index) in pics"
          :src="item"
          :key="index"
          fit="fill"
        ></el-image>
      </div>
      <div class="content">{{ content.content }}</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      strategyId: this.$route.query.strategyId,
      content: {},
      pics: [],
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      this.$axios
        .post("/static/strategy/info", {
          strategyId: this.strategyId,
        })
        .then((res) => {
          if (res.data.code === 0) {
            this.content = res.data.page;
            this.pics = this.content.pics.split(",");
            console.log(this.content);
          }
        });
    },
    back() {
      this.$router.push( {path: '/', query: { activeIndex: '4' }} );
    },
  },
};
</script>

<style scoped>
.raider_detail_wrap {
  width: 1200px;
  margin: 0 auto;
  background-color: #fff;
  padding-top: 20px;
}
.el-button {
  font-size: 18px;
  margin-bottom: 15px;
}
.content_wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.title {
  font-size: 24px;
  font-weight: bold;
  line-height: 40px;
}
.writer,
.createTime,
.updateTime {
  font-size: 18px;
  line-height: 30px;
}
.el-image {
  max-width: 900px;
  max-height: 600px;
  margin: 15px 0;
}
.content {
  width: 100%;
  font-size: 18px;
  line-height: 25px;
  text-indent: 2rem;
  text-align: left;
  padding: 0 20px;
}

</style>
